package com.cw.jeeyt.config.process;

import org.flowable.ui.modeler.properties.FlowableModelerAppProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FlowableBeanConfig {
    protected static final String LIQUIBASE_CHANGELOG_PREFIX = "ACT_DE_";

    //	@Bean
    //	public FlowableCommonAppProperties flowableCommonAppProperties() {
    //		FlowableCommonAppProperties flowableCommonAppProperties = new FlowableCommonAppProperties();
    //		flowableCommonAppProperties.setIdmUrl("http://localhost:8080/flowable-idm");
    //		Admin idmAdmin = flowableCommonAppProperties.getIdmAdmin();
    //		idmAdmin.setUser("admin");
    //		idmAdmin.setPassword("test");
    //		return flowableCommonAppProperties;
    //	}
    @Bean
    public FlowableModelerAppProperties flowableModelerAppProperties() {
        FlowableModelerAppProperties flowableModelerAppProperties = new FlowableModelerAppProperties();
        return flowableModelerAppProperties;
    }

    // @Bean
    // public Liquibase liquibase(DataSource dataSource) {
    //     LOGGER.info("Configuring Liquibase");
    //
    //     try {
    //         DatabaseConnection connection = new JdbcConnection(dataSource.getConnection());
    //         Database database = DatabaseFactory.getInstance()
    //             .findCorrectDatabaseImplementation(connection);
    //         database.setDatabaseChangeLogTableName(
    //             LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogTableName());
    //         database.setDatabaseChangeLogLockTableName(
    //             LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogLockTableName());
    //
    //         Liquibase liquibase = new Liquibase("META-INF/liquibase/flowable-modeler-app-db-changelog.xml",
    //             new ClassLoaderResourceAccessor(), database);
    //         liquibase.update("flowable");
    //         return liquibase;
    //
    //     } catch (Exception e) {
    //         throw new RuntimeException("Error creating liquibase database", e);
    //     }
    // }
}
